home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 26
/
Commodore_Free_Issue_26_2009_Commodore_Computer_Club.d64
/
-part 2
next >
Wrap
Text File
|
2023-02-26
|
10KB
|
328 lines
u IN THE BEGINNING 11
part 2
by Lord Ronin
OK but we have to tell the sprite to
do that, and that is done in line 80.
Where we have pokev+4,x. Same as line
40. But here the x variable is the 0
to 63. See how that works? First the x
variable is the 0 to 255, and then it
becomes the 0 to 63. This takes us the
rest of the way across the screen.
Final part of that piece is line 90.
Where we have the next for the
for-next loop. Since there isn't any
variable in use past the x one, there
isn't a need to tell the for next loop
to do a next x. Computer has that as
implied, we didn't give it any other
variable to work with at that time.
New at line 100, looks kind of
familiar, here we poke v+16,0. Well we
got the poke part and the v variable
part, just started to understand the
+16 part. You remember turning on the
MSB. What the frell does that 0 mean?
A big nothing? Sort of, remember back
a bit when we were doing the chart
stuff. Like the sprite drawings? There
it was a 1 meant something was there
or turned on, while a 0 meant that
there was nothing there or turned off,
on this line that 0 means that we are
turning off that MSB part of the
sprite. That allows the whole thing to
start over again, with line 110 in the
goto command.
But here is what they say in regards
to defining multiple sprites, we may
need additional blocks for the sprite
data, OK I can follow that part. As I
suspect that this is the beginning of
how to have more than 8 sprites.
Remember that 8 are all that can be
active at one time; you can have
others in the "wings" waiting to be
used though. They then tell us that we
can use some of the "Basic's RAM by
moving Basic, before typing or loading
your programme type:" Get to that in a
moment.
POKE44,16:POKE16*256,0:NEW
This sets up to use blocks 32 through
41, these are memory locations 2048
through 4095, "To store sprite data."
Right 64 bytes for each sprite, I am
not sure of the block part or the 1044
memory locations that exist in the
above. Suffice that it works and gives
you more areas for your sprites. You
may remember that 2040 is the memory
for sprite 0, making sprite 8 at 2047,
this starts one off at the spot right
after sprite #8. Anyway feel free to
play with some of the numbers in the
program above and see what happens.
Add at this point sprites are more
than we have seen here in the series
and the user's book; I haven't talked
about controlling them with the
joystick or keyboard, nor anything
about multicolour sprites. I haven't
even talked about multicolour custom
fonts either, none of that is in the
users manual.
Now back to the book and their
beginnings on binary math. We actually
have been doing some of this without
knowing it with those charts for the
balloon and sprite locations, that on
and off part. Well we aren't going to
spend a lot of time on this part; I
had it and failed it in college. First
we have some terms to explain; well
the book starts out that way in this
area. BIT is the smallest part of
information that the computer can
store, basically something is there or
not, the on/off thing. If there is
something there, the value is 1. If it
is empty then the value is 0. Right
like those chart things earlier for
the sprite creation and location
stuff. The book goes into a BYTE next,
this is a series of BITS, since we are
an 8 bit machine; A BYTE for us is
composed of 8 bits. Hmm wasn't the
number of slots in that sprite row,
and say isn't that the same amount of
sprites that can be on the screen
active?
OK now I have to add some information
that isn't in the book, because you
may have heard the terms in regards to
the C= in the past. NIBBLE, isn't in
the book, the term comes from crackers
and hackers, so I was told by some of
them. NIBBLE is 4 BITS, yeah half a
BYTE. This is one of the early copy
systems, called a nibbler. Sorry we
had it before the Futurama show, but
then again Matt tosses in a lot of
C=64 things in that show. Back on
topic; You may find in your disk
collection that you have a tool called
a "nibble copy" or a "nibbler", That
will copy a disk at 4 bits at a time,
this Broke early copy protection.
Another word that you have heard in
here in the early part, and will see
on your disks, is a BLOCK. Commodore
measures things in BLOCKS, as I said
before. We have been doing things with
bits most recently; I wanted to let
you know that these measurements of
block and bits/bytes will be tossed
around a lot, and Used by users,
programmers, coders, manufacturers and
more. Gets real confusing at times,
when they start tossing out KiloBytes,
Bytes and blocks; For the record a C=
block is a 256 bit unit. Roughly 4 of
them will make 1 kilobyte.
Saying all of that trivia, here is
your next thing to play upon; On the
regular screen, save the balloon stuff
if you wish, I want you to do some
simple math problems. We are going to
raise a number, What I want you to do
is type in ...
? 20 <and then press return>
Now then just cursor up and over the
0 and change it to a 1, then a 2 a 3 a
4 a 5 a 6 and finally a 7. You will
see that it goes the same 1 through
128 values we have dealt with before.
I just think that this is easier than
making the chart in the book to show
you the same smegging thing. Now there
is a program to type in and I strongly
suggest that you save this one.
5 rem binary to decimal converter
10 input"enter 8-bit binary
number:";a$
12 iflen(a$)<>8then?"8 bits
please...":goto10
15 tl=0:c=0
20 forx=8to1step-1:c=c+1
30 tl=tl+val(mid$(a$,c,1))*2(x-1)
40 nextx
50 ?a$;"binary ";" = ";tl;"decimal"
60 goto10
Line 30 is the one that most of the
group here, self included, frell up.
Forgetting to do )) after the 1 and
before the *. The programme will take
an 8 character binary number, like
11111111 and tell you what the decimal
value of it is, and for here it is
255. There are a couple new commands
in this one that are lightly discussed
in the book, VAL is for VALue, Gives
us the actual value of the character
as a numeric form. MID$, also called
"mid-string", and takes a look at each
character in the string, from left to
right. C variable in that string in
line 30 tells the program what
character to work upon as the program
goes through the loop. There is a lot
more to the usage of these two new
commands. Not all that needed for this
level of understanding. Last part of
that line raises the number to a power
of 2. That x-1 just keeps it in track,
Starting off at 27 and each time
through the loop dropping by one, till
it reaches 20. Locale group lesson is
to count on this thing from 0 to 255,
in decimal, by typing the binary
values, sounds tough I know; and it
took me two hours the first time,
however there is a pattern. If you
have that chart at hand, the one that
starts at the left with 128 and ends
with 1 on the right, You can see the
pattern a lot faster.
Page 79 starts on sound creating, the
book ends at 103, starting all the
appendices. Lot to cover and we aren't
going to make it at all; No reason too
either. If you have followed through
to this to this point, you understand
that there is a lot more to
programming than we can cover in these
instalments'. Just for Basic, let's
not mention other forms of programming
languages. You may have also thought
that you are not interested in
programming; in either case there are
other sources than just my lame
drivel.
Sound is not a something that I am
not comfortable with at this time. Not
because I can't read music to some
degree, no because there is a lot of
complicated things here for the
beginner; and the fact that not all of
the 64 user manual examples work on
the later SID chip, Like this 128Dcr I
am using.
What I am going to do is lay out some
type in things that did work on this
C=PC. Leaving off a lot of
explanations and just having you see
that you can make sounds on the
system. Big books cover this topic
better than I or this manual can/did.
Like I said earlier on, and for
sprites as well; there are programming
tools that will do this work for you.
One I did was just put the note on the
staff and select the musical
instrument, sound effects may be a bit
harder for games, or not. The book
tells us about the ADSR; The Attack
Delay Sustain and Release of the
sound, the waveform control and hi/lo
frequency. First three settings are
generally done just once for the
programme, Hi/Lo is done for each note
and waveform is the start and stop for
each note. That said, the first type
in thing in the book failed on the 64c
and on the 128Dcr in 64 mode: But the
next one worked, and they did some
additives for different sounds in the
instructions, OK type in the
following... without my comments
5 rem musical scale
7 forl=54272to54296:pOl,0:next
10 pO54296,15 <that sets the volume to
the highest level of 15>
20 pO54277,9 <sets the attack & decay>
30 pO54276,17 <determines the
waveform, or type of sound>
40 fort=1to300:next <duration of the
sound>
50 reada <reads first number in data
statement on line 110>
60 readb <reads 2nd number in data
statement on line 110>
70 ifb=-1thenend <turns off at value
in line 900>
80 pO54273,a:pO54272,b <pokes first
data number as the hi frequency and
2nd number as lo frequency>
85 pO54276,17 <starts the note>
90 fort=1to250:next:pO54276,16 <play
and stop the note>
95 fort=1to50:next <release time>
100 goto20 <loops back for new note>
110 data17,37,19,63,21,154,22,227
<musical note vales, listed in book>
120 data25,177,28,214,32,94,34,175
<Each of these pairs is one note>
900 data-1,-1 <turns off hi/lo and
ends the prg>
Not a great explanation. They take a
few pages to explain things, run the
program and you should hear an 8 note
musical scale. Once tired of that,
change line 85 to read pO54276,33 and
90 to fort=1to250:next:pO54276,32.
You'll get a sort of harpsichord
sound.
This is just one of the three voices
and a couple of the different
waveforms that can be used. Scare you
now with the added information that
there are those that have added a
second SID chip, or a cart and do this
in Stereo. Most popular music player
for the c= 64 is the Stereo SID
player, OK one last one that worked, A
sound effect to try out. For a gun
shot
10v=54296:w=54276:a=54277:
h=54273:l=54272
20 forx=15to0step-1:pOv,x:pOw,129:
pOa,15:pOh,40:pOl,200:next
30 pOw,0:pOa,0
Continued Next Month